<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="Hexo Theme Keep">
    <meta name="description" content="Hexo Theme Keep">
    <meta name="author" content="cm_westwood">
    
    <title>
        
            第11周 |
        
        西木同学的代码训练 2022
    </title>
    
<link rel="stylesheet" href="/code_training_2022/css/style.css">

    <link rel="shortcut icon" href="">
    
<link rel="stylesheet" href="/code_training_2022/css/font-awesome.min.css">

    <script id="hexo-configurations">
    let KEEP = window.KEEP || {};
    KEEP.hexo_config = {"hostname":"cm_westwood.gitee.io","root":"/code_training_2022/","language":"en","path":"search.json"};
    KEEP.theme_config = {"toc":{"enable":true,"number":true,"expand_all":true,"init_open":true},"style":{"primary_color":"#0066CC","avatar":"","favicon":"","article_img_align":"left","left_side_width":"260px","content_max_width":"920px","hover":{"shadow":false,"scale":false},"first_screen":{"enable":true,"background_img":"https://xpoet.cn/images/bg.svg","description":"Keep writing and Keep loving."},"scroll":{"progress_bar":{"enable":true},"percent":{"enable":true}}},"local_search":{"enable":true,"preload":false},"code_copy":{"enable":true,"style":"default"},"pjax":{"enable":false},"lazyload":{"enable":true},"version":"3.4.5"};
    KEEP.language_ago = {"second":"%s seconds ago","minute":"%s minutes ago","hour":"%s hours ago","day":"%s days ago","week":"%s weeks ago","month":"%s months ago","year":"%s years ago"};
  </script>
<meta name="generator" content="Hexo 6.2.0"></head>


<body>
<div class="progress-bar-container">
    
        <span class="scroll-progress-bar"></span>
    

    
</div>


<main class="page-container">

    

    <div class="page-main-content">

        <div class="page-main-content-top">
            <header class="header-wrapper">

    <div class="header-content">
        <div class="left">
            
            <a class="logo-title" href="/">
                西木同学的代码训练 2022
            </a>
        </div>

        <div class="right">
            <div class="pc">
                <ul class="menu-list">
                    
                        <li class="menu-item">
                            <a class=""
                               href="/code_training_2022/"
                            >
                                HOME
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/code_training_2022/archives"
                            >
                                ARCHIVES
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/code_training_2022/tags"
                            >
                                TAGS
                            </a>
                        </li>
                    
                    
                        <li class="menu-item search search-popup-trigger">
                            <i class="fas fa-search"></i>
                        </li>
                    
                </ul>
            </div>
            <div class="mobile">
                
                    <div class="icon-item search search-popup-trigger"><i class="fas fa-search"></i></div>
                
                <div class="icon-item menu-bar">
                    <div class="menu-bar-middle"></div>
                </div>
            </div>
        </div>
    </div>

    <div class="header-drawer">
        <ul class="drawer-menu-list">
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/code_training_2022/">HOME</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/code_training_2022/archives">ARCHIVES</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/code_training_2022/tags">TAGS</a>
                </li>
            
        </ul>
    </div>

    <div class="window-mask"></div>

</header>


        </div>

        <div class="page-main-content-middle">

            <div class="main-content">

                
                    <div class="fade-in-down-animation">
    <div class="article-content-container">

        <div class="article-title">
            <span class="title-hover-animation">第11周</span>
        </div>

        
            <div class="article-header">
                <div class="avatar">
                    <img src="">
                </div>
                <div class="info">
                    <div class="author">
                        <span class="name">cm_westwood</span>
                        
                            <span class="author-label">Lv2</span>
                        
                    </div>
                    <div class="meta-info">
                        <div class="article-meta-info">
    <span class="article-date article-meta-item">
        <i class="fas fa-edit"></i>&nbsp;
        <span class="pc">2023-01-15 16:41:44</span>
        <span class="mobile">2023-01-15 16:41</span>
    </span>
    
    
        <span class="article-tags article-meta-item">
            <i class="fas fa-tags"></i>&nbsp;
            <ul>
                
                    <li>
                        <a href="/code_training_2022/tags/Python/">Python</a>&nbsp;
                    </li>
                
                    <li>
                        | <a href="/code_training_2022/tags/Docker/">Docker</a>&nbsp;
                    </li>
                
            </ul>
        </span>
    

    
    
    
    
</div>

                    </div>
                </div>
            </div>
        

        <div class="article-content markdown-body">
            <p>printf  风格的字符串格式化；强制 python 使用特定版本的包；从特定路径导入 python 的包；python setup.py 安装一些静态文件；开源库的搜索引擎；docker 镜像和宿主机通信；</p>
<span id="more"></span>

<h1 id="printf-风格的字符串格式化"><a href="#printf-风格的字符串格式化" class="headerlink" title="printf  风格的字符串格式化"></a>printf  风格的字符串格式化</h1><p>python 中的 % 格式化字符串还是非常好用的，现在很多 SQL 格式化参数用的都是这种风格，而关于这种用法现在是很难在搜索引擎上找得到了，搜出来都是些 format 的用法，还是官方文档这里写的清楚</p>
<blockquote>
<p><a class="link"   target="_blank" rel="noopener" href="https://docs.python.org/zh-cn/3.8/library/stdtypes.html#old-string-formatting" >内置类型 — Python 3.8.14 文档<i class="fas fa-external-link-alt"></i></a></p>
</blockquote>
<h1 id="强制-python-使用特定版本的包"><a href="#强制-python-使用特定版本的包" class="headerlink" title="强制 python 使用特定版本的包"></a>强制 python 使用特定版本的包</h1><p>如果 python sys.path 下有两个版本的库，那么是否可以通过这种方式来指定特定版本的包呢？</p>
<blockquote>
<p><a class="link"   target="_blank" rel="noopener" href="https://stackoverflow.com/questions/22565463/how-do-i-force-python-to-use-a-specific-version-of-a-module" >如何“强制”python 使用特定版本的模块？ - 堆栈溢出<i class="fas fa-external-link-alt"></i></a></p>
</blockquote>
<h1 id="从特定路径导入-python-的包"><a href="#从特定路径导入-python-的包" class="headerlink" title="从特定路径导入 python 的包"></a>从特定路径导入 python 的包</h1><p>不想改动 sys.path 里面现有的 python 包路径而想从特定的路径导入包</p>
<blockquote>
<p><a class="link"   target="_blank" rel="noopener" href="https://www.geeksforgeeks.org/how-to-import-a-python-module-given-the-full-path/" >How to import a Python module given the full path? - GeeksforGeeks<i class="fas fa-external-link-alt"></i></a></p>
</blockquote>
<h1 id="python-setup-py-安装一些静态文件"><a href="#python-setup-py-安装一些静态文件" class="headerlink" title="python setup.py 安装一些静态文件"></a>python setup.py 安装一些静态文件</h1><p>python 想打包一些 CDN 静态文件脚本，而这些静态文件我们是不希望它也被 git 识别而加入到代码库里的，所以我们可以在打包的时候使用 wget 先下载静态文件，然后用 setup.py 里的 data_files 配置将这些静态文件安装到指定目录</p>
<blockquote>
<p><a class="link"   target="_blank" rel="noopener" href="https://stackoverflow.com/questions/27829754/include-entire-directory-in-python-setup-py-data-files" >Include entire directory in python setup.py data_files - Stack Overflow<i class="fas fa-external-link-alt"></i></a></p>
</blockquote>
<h1 id="开源库的搜索引擎"><a href="#开源库的搜索引擎" class="headerlink" title="开源库的搜索引擎"></a>开源库的搜索引擎</h1><p>github 自带的搜索引擎没有这个网站好用</p>
<blockquote>
<p><a class="link"   target="_blank" rel="noopener" href="https://awesomeopensource.com/projects/dashboard/golang" >The Top 359 Golang Dashboard Open Source Projects<i class="fas fa-external-link-alt"></i></a></p>
<p><a class="link"   target="_blank" rel="noopener" href="https://awesomeopensource.com/project/ml-tooling/best-of-jupyter" >Best Of Jupyter<i class="fas fa-external-link-alt"></i></a></p>
</blockquote>
<h1 id="docker-镜像和宿主机通信"><a href="#docker-镜像和宿主机通信" class="headerlink" title="docker 镜像和宿主机通信"></a>docker 镜像和宿主机通信</h1><p>或许可以通过这个调用宿主机的命令而不用每个镜像都要去安装某个命令环境？</p>
<blockquote>
<p><a class="link"   target="_blank" rel="noopener" href="https://blog.csdn.net/boling_cavalry/article/details/92846483" >(175条消息) docker的&#x2F;var&#x2F;run&#x2F;docker.sock参数_程序员欣宸的博客-CSDN博客_&#x2F;var&#x2F;run&#x2F;docker.sock<i class="fas fa-external-link-alt"></i></a></p>
<p><a class="link"   target="_blank" rel="noopener" href="https://docs.docker.com/engine/api/v1.39/#tag/Exec/operation/ContainerExec" >Docker Engine API v1.39 Reference<i class="fas fa-external-link-alt"></i></a></p>
</blockquote>

        </div>

        

        
            <ul class="post-tags-box">
                
                    <li class="tag-item">
                        <a href="/code_training_2022/tags/Python/">#Python</a>&nbsp;
                    </li>
                
                    <li class="tag-item">
                        <a href="/code_training_2022/tags/Docker/">#Docker</a>&nbsp;
                    </li>
                
            </ul>
        

        
            <div class="article-nav">
                
                
                    <div class="article-next">
                        <a class="next"
                           rel="next"
                           href="/code_training_2022/2023/01/02/%E7%AC%AC10%E5%91%A8/"
                        >
                            <span class="title flex-center">
                                <span class="post-nav-title-item">第10周</span>
                                <span class="post-nav-item">Next posts</span>
                            </span>
                            <span class="right arrow-icon flex-center">
                              <i class="fas fa-chevron-right"></i>
                            </span>
                        </a>
                    </div>
                
            </div>
        

        
    </div>
</div>


                
            </div>

        </div>

        <div class="page-main-content-bottom">
            <footer class="footer">
    <div class="info-container">
        <div class="copyright-info info-item">
            &copy;
            
              <span>2022</span>
              -
            
            2023&nbsp;<i class="fas fa-heart icon-animate"></i>&nbsp;<a href="/">cm_westwood</a>
        </div>
        
        <div class="theme-info info-item">
            Powered by <a target="_blank" href="https://hexo.io">Hexo</a>&nbsp;|&nbsp;Theme&nbsp;<a class="theme-version" target="_blank" href="https://github.com/XPoet/hexo-theme-keep">Keep v3.4.5</a>
        </div>
        
        
    </div>
</footer>

        </div>
    </div>

    
        <div class="post-tools">
            <div class="post-tools-container">
    <ul class="tools-list">
        <!-- TOC aside toggle -->
        
            <li class="tools-item page-aside-toggle">
                <i class="fas fa-outdent"></i>
            </li>
        

        <!-- go comment -->
        
    </ul>
</div>

        </div>
    

    <div class="right-bottom-side-tools">
        <div class="side-tools-container">
    <ul class="side-tools-list">
        <li class="tools-item tool-font-adjust-plus flex-center">
            <i class="fas fa-search-plus"></i>
        </li>

        <li class="tools-item tool-font-adjust-minus flex-center">
            <i class="fas fa-search-minus"></i>
        </li>

        <li class="tools-item tool-expand-width flex-center">
            <i class="fas fa-arrows-alt-h"></i>
        </li>

        <li class="tools-item tool-dark-light-toggle flex-center">
            <i class="fas fa-moon"></i>
        </li>

        <!-- rss -->
        

        

        <li class="tools-item tool-scroll-to-bottom flex-center">
            <i class="fas fa-arrow-down"></i>
        </li>
    </ul>

    <ul class="exposed-tools-list">
        <li class="tools-item tool-toggle-show flex-center">
            <i class="fas fa-cog fa-spin"></i>
        </li>
        
            <li class="tools-item tool-scroll-to-top flex-center">
                <i class="arrow-up fas fa-arrow-up"></i>
                <span class="percent"></span>
            </li>
        
    </ul>
</div>

    </div>

    
        <aside class="page-aside">
            <div class="post-toc-wrap">
    <div class="post-toc">
        <ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#printf-%E9%A3%8E%E6%A0%BC%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%A0%BC%E5%BC%8F%E5%8C%96"><span class="nav-number">1.</span> <span class="nav-text">printf  风格的字符串格式化</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%BC%BA%E5%88%B6-python-%E4%BD%BF%E7%94%A8%E7%89%B9%E5%AE%9A%E7%89%88%E6%9C%AC%E7%9A%84%E5%8C%85"><span class="nav-number">2.</span> <span class="nav-text">强制 python 使用特定版本的包</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BB%8E%E7%89%B9%E5%AE%9A%E8%B7%AF%E5%BE%84%E5%AF%BC%E5%85%A5-python-%E7%9A%84%E5%8C%85"><span class="nav-number">3.</span> <span class="nav-text">从特定路径导入 python 的包</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#python-setup-py-%E5%AE%89%E8%A3%85%E4%B8%80%E4%BA%9B%E9%9D%99%E6%80%81%E6%96%87%E4%BB%B6"><span class="nav-number">4.</span> <span class="nav-text">python setup.py 安装一些静态文件</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%BC%80%E6%BA%90%E5%BA%93%E7%9A%84%E6%90%9C%E7%B4%A2%E5%BC%95%E6%93%8E"><span class="nav-number">5.</span> <span class="nav-text">开源库的搜索引擎</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#docker-%E9%95%9C%E5%83%8F%E5%92%8C%E5%AE%BF%E4%B8%BB%E6%9C%BA%E9%80%9A%E4%BF%A1"><span class="nav-number">6.</span> <span class="nav-text">docker 镜像和宿主机通信</span></a></li></ol>
    </div>
</div>
        </aside>
    

    <div class="image-viewer-container">
    <img src="">
</div>


    
        <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
          <span class="search-input-field-pre">
            <i class="fas fa-keyboard"></i>
          </span>
            <div class="search-input-container">
                <input autocomplete="off"
                       autocorrect="off"
                       autocapitalize="off"
                       placeholder="Search..."
                       spellcheck="false"
                       type="search"
                       class="search-input"
                >
            </div>
            <span class="popup-btn-close">
                <i class="fas fa-times"></i>
            </span>
        </div>
        <div id="search-result">
            <div id="no-result">
                <i class="fas fa-spinner fa-pulse fa-5x fa-fw"></i>
            </div>
        </div>
    </div>
</div>

    

</main>




<script src="/code_training_2022/js/utils.js"></script>

<script src="/code_training_2022/js/main.js"></script>

<script src="/code_training_2022/js/header-shrink.js"></script>

<script src="/code_training_2022/js/back2top.js"></script>

<script src="/code_training_2022/js/dark-light-toggle.js"></script>



    
<script src="/code_training_2022/js/local-search.js"></script>




    
<script src="/code_training_2022/js/code-copy.js"></script>




    
<script src="/code_training_2022/js/lazyload.js"></script>



<div class="post-scripts">
    
        
<script src="/code_training_2022/js/left-side-toggle.js"></script>

<script src="/code_training_2022/js/libs/anime.min.js"></script>

<script src="/code_training_2022/js/toc.js"></script>

    
</div>



</body>
</html>
